import md5 from "blueimp-md5"
import { post, DCAPI, get } from "libs/api"
window.md5 = md5
const USER = `${DCAPI}user/`

export function login ({ userLoginName, pwd }) {
  return post(`${USER}login`, {
    headers: {
      "Content-type": "application/json"
    },
    body: JSON.stringify({
      userLoginName,
      pwd: md5(md5(pwd))
      // pwd: pwd
    })
  })
}

export function logOut () {
  return get(`${USER}logout`)
}

export function changePwd (query) {
  return post(`${USER}updateDataUserPwd`, JSON.stringify(query))
}

// 密码校验
export function confirmPwd (pwd) {
  return get(`${USER}confirmDelete/${md5(md5(pwd))}`)
}
